﻿using System;
using System.Collections.Generic;
using System.Data;
using DotNetHelper.ObjectToSql.Enum;

namespace DotNetHelper.ObjectToSql.Helper
{
	public class DbTypeMap
	{
		public Dictionary<Type, DbType> TypeToSqlTypeMap { get; }
		public DbTypeMap(DataBaseType dataBaseType)
		{
			switch (dataBaseType)
			{
				case DataBaseType.SqlServer:
					break;
				case DataBaseType.MySql:
					break;
				case DataBaseType.Sqlite:
					break;
				case DataBaseType.Oracle:
					break;
				case DataBaseType.Oledb:
					break;
				case DataBaseType.Access95:
					break;
				case DataBaseType.Odbc:
					break;
				default:
					throw new ArgumentOutOfRangeException(nameof(dataBaseType), dataBaseType, null);
			}
			TypeToSqlTypeMap = new Dictionary<Type, DbType>
			{
				[typeof(byte)] = DbType.Byte,
				[typeof(sbyte)] = DbType.SByte,
				[typeof(short)] = DbType.Int16,
				[typeof(ushort)] = DbType.UInt16,
				[typeof(int)] = DbType.Int32,
				[typeof(uint)] = DbType.UInt32,
				[typeof(long)] = DbType.Int64,
				[typeof(ulong)] = DbType.UInt64,
				[typeof(float)] = DbType.Single,
				[typeof(double)] = DbType.Double,
				[typeof(decimal)] = DbType.Decimal,
				[typeof(bool)] = DbType.Boolean,
				[typeof(string)] = DbType.String,
				[typeof(char)] = DbType.StringFixedLength,
				[typeof(Guid)] = DbType.Guid,
				[typeof(DateTime)] = DbType.DateTime,
				[typeof(DateTimeOffset)] = DbType.DateTimeOffset,
				[typeof(TimeSpan)] = DbType.Time,
				[typeof(byte[])] = DbType.Binary,
				[typeof(byte?)] = DbType.Byte,
				[typeof(sbyte?)] = DbType.SByte,
				[typeof(short?)] = DbType.Int16,
				[typeof(ushort?)] = DbType.UInt16,
				[typeof(int?)] = DbType.Int32,
				[typeof(uint?)] = DbType.UInt32,
				[typeof(long?)] = DbType.Int64,
				[typeof(ulong?)] = DbType.UInt64,
				[typeof(float?)] = DbType.Single,
				[typeof(double?)] = DbType.Double,
				[typeof(decimal?)] = DbType.Decimal,
				[typeof(bool?)] = DbType.Boolean,
				[typeof(char?)] = DbType.StringFixedLength,
				[typeof(Guid?)] = DbType.Guid,
				[typeof(DateTime?)] = DbType.DateTime,
				[typeof(DateTimeOffset?)] = DbType.DateTimeOffset,
				[typeof(TimeSpan?)] = DbType.Time,
				[typeof(object)] = DbType.Object
			};
		}
	}
}